#include "SsiUpdateTask.h"
#include "../packages/ssi/SrvSsiXModXAck.h"

namespace Impp
{

SsiUpdateTask::SsiUpdateTask(Oscar* oscar, Buddy* buddy,const qword  & requestId, const SsiUpdateType & type,const int & privacyList) :
	Task(TASK_SSI_UPDATE, oscar,TASK_HANDLE_REQUESTID,requestId,(time_t)12), buddy(buddy),type(type),privacyList(privacyList)
{
}

SsiUpdateTask::~SsiUpdateTask()
{
}

void SsiUpdateTask::timedOut(){
	wxLogDebug(wxT("SsiUpdateTask::timedOut: failed!"));
	switch (type) {
		case SSI_UPDATE_RENAME_BUDDY:
			wxLogDebug(wxT("SsiUpdateTask::timedOut: Renaming: %s failed"), buddy->getName().c_str());
			break;
		case SSI_UPDATE_ADD_TO_PRIVACY_LIST:
			wxLogDebug(wxT("SsiUpdateTask::timedOut: add to privacylist: %s failed"), buddy->getName().c_str());
			break;
		case SSI_UPDATE_REMOVE_FROM_PRIVACY_LIST:
			wxLogDebug(wxT("SsiUpdateTask::timedOut: remove from privacylist: %s failed"), buddy->getName().c_str());
			break;
		default:
			break;
	}
	
}

bool SsiUpdateTask::ssiXModXAck(word code){
	switch (type) {
		case SSI_UPDATE_RENAME_BUDDY:
			if(code == SSI_STAUTS_NO_ERRORS){
				wxLogDebug(wxT("SsiUpdateTask::SsiUpdateTask: Renaming: %s successfull"), buddy->getName().c_str());
			}else{
				wxLogDebug(wxT("SsiUpdateTask::SsiUpdateTask: Renaming: %s failed"), buddy->getName().c_str());
			}
			break;
		case SSI_UPDATE_ADD_TO_PRIVACY_LIST:
			if(code == SSI_STAUTS_NO_ERRORS){
				wxLogDebug(wxT("SsiUpdateTask::SsiUpdateTask: add to privacylist: %s successfull"), buddy->getName().c_str());
			}else{
				wxLogDebug(wxT("SsiUpdateTask::SsiUpdateTask: add to privacylist: %s failed"), buddy->getName().c_str());
			}
			break;
		case SSI_UPDATE_REMOVE_FROM_PRIVACY_LIST:
			if(code == SSI_STAUTS_NO_ERRORS){
				wxLogDebug(wxT("SsiUpdateTask::SsiUpdateTask:remove from privacylist: %s successfull"), buddy->getName().c_str());
			}else{
				wxLogDebug(wxT("SsiUpdateTask::SsiUpdateTask: remove from privacylist: %s failed"), buddy->getName().c_str());
			}
			break;
		default:
			break;
	}
	return true;
}

}
